package com.xian.im.message.producer;

import com.xian.im.common.constant.CommandConstant;
import com.xian.im.common.enums.ConsumerQueueEnum;
import com.xian.im.common.model.session.SessionUser;
import com.xian.im.common.utils.template.RabbitTemplateUtil;
import com.xian.im.message.model.QueueMsg;
import io.netty.channel.ChannelHandlerContext;

/**
 * @program: xian-im-server
 * @description:
 * @author: liru.xian
 * @create: 2021-03-01 10:15
 **/
public class P2PProducer implements MessageProducer {
    /**
     *
     */
    @Override
    public void doHandler(QueueMsg message, SessionUser session, ChannelHandlerContext ctx) {
        message.getMsgRequest().setFromAccount(session.getAccount());
        message.setAnEnum(ConsumerQueueEnum.CONSUMER_USER);
        RabbitTemplateUtil.sendMes(ConsumerQueueEnum.CONSUMER_USER.getExchange(),ConsumerQueueEnum.CONSUMER_USER.getFactoryName(),message);
    }

    /**
     * @return
     */
    @Override
    public Integer getType() {
        return CommandConstant.P2P_CMD;
    }
}
